<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>无缝滚动-js</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }
        
        a {
            text-decoration: none;
        }
        
        #box {
            margin: 100px auto;
            width: 600px;
            height: 200px;
            position: relative;
        }
        
        #div1 {
            width: 600px;
            height: 200px;
            /* background: red; */
            /* border: 1px solid blue; */
            position: relative;
            overflow: hidden;
        }
        
        #div1 ul {
            width: 2000px;
            height: 200px;
            position: absolute;
            left: 0;
            list-style: none;
        }
        
        #div1 ul li {
            width: 200px;
            height: 200px;
            float: left;
        }
        
        #div1 ul li img {
            width: 200px;
            height: 200px;
        }
        
        #div1 div {
            float: left;
            z-index: 999;
            display: block;
            width: 20px;
            height: 30px;
        }
        
        #slider-ctr a {
            width: 20px;
            height: 40px;
            background: black;
            opacity: 0.4;
            position: absolute;
            top: 80px;
            text-align: center;
            line-height: 40px;
            font-size: 30px;
            color: white;
            display: none;
        }
        
        #box:hover #slider-ctr a {
            display: inline-block;
        }
        
        #slider-ctr .prv {
            left: 0;
        }
        
        #slider-ctr .next {
            left: 580px;
        }
    </style>
    <script type="text/javascript">
        window.onload = function() {
            var div1 = document.getElementById("div1");
            var ul = div1.getElementsByTagName("ul")[0];
            var a = document.getElementsByTagName("a");
            var timer = null;
            var speed = 3;

            function move() {
                if (ul.offsetLeft < -1400) {
                    ul.style.left = "0px";
                }
                if (ul.offsetLeft > 0) {
                    ul.style.left = "-1400px";
                }
                ul.style.left = ul.offsetLeft + speed + "px";
            }
            var timer2 = setInterval(function() {
                clearInterval(timer);
                setTimeout(function() {
                    timer = setInterval(move, 3)

                }, 2400);
            }, 3000);
            a[0].onclick = function() {
                speed = -3;
                move();
            }
            a[1].onclick = function() {
                speed = 3;
                move();
            }
            ul.onmouseover = function() {
                clearInterval(timer2);
                clearInterval(timer);
            }
            ul.onmouseout = function() {
                timer2 = setInterval(function() {
                    clearInterval(timer);
                    setTimeout(function() {
                        timer = setInterval(move, 3)

                    }, 2400);
                }, 3000);
            }




        }
    </script>
</head>

<body>
    <div id="box">
        <div id="div1">
            <ul>
                <li><img src="images/5.jpg" alt=""></li>
                <li><img src="images/6.jpg" alt=""></li>
                <li><img src="images/7.jpg" alt=""></li>
                <li><img src="images/8.jpg" alt=""></li>
                <li><img src="images/9.jpg" alt=""></li>
                <li><img src="images/10.jpg" alt=""></li>
                <li><img src="images/11.jpg" alt=""></li>
                <li><img src="images/12.jpg" alt=""></li>
                <li><img src="images/13.jpg" alt=""></li>
                <li><img src="images/14.jpg" alt=""></li>
            </ul>
        </div>
        <div id="slider-ctr">
            <a href="javascript:void(0)" class="prv">
                <</a>
                    <a href="javascript:void(0)" class="next">></a>
        </div>
    </div>

</body>

</html>